package hy.util;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.util.ByteSource;

public class PassUtil {
    public static String encode(String pass,String salt){
		//可加盐值的md5算法
		Md5Hash md = new Md5Hash(pass,salt);
		return md.toString();
	}
	
	//随机生成盐值
	public static String randomSalt(){
		//UUID.randomUUID().toString(),下面是shiro提供的随机字符串
		SecureRandomNumberGenerator gen = new SecureRandomNumberGenerator();
		ByteSource nb = gen.nextBytes();
		return new String(nb.getBytes());
	}	
}